package com.silence.FinalTest;

import java.util.*;

public class Q3 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int len = scan.nextInt();
            int[] arr = new int[len];
            int times = 0;
            for (int i = 0; i < len; i++) {
                arr[i] = scan.nextInt();
            }
            for (int i = 0; i < arr.length - 1; i++) {
                for (int j = 0; j < arr.length-i-1; j++) {
                    if(arr[j] > arr[j+1]){
                        int temp = arr[j+1];
                        arr[j+1] = arr[j];
                        arr[j] = temp;
                        times ++;
                    }
                }
            }
            System.out.println(times);
        }
    }
}
